package com.example.zhihuhelpapp.activity;

import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;

import com.example.zhihuhelpapp.R;
import com.example.zhihuhelpapp.base.BaseActivity;
import com.example.zhihuhelpapp.utils.CoreConstant;
import com.example.zhihuhelpapp.utils.SpUtils;
import com.example.zhihuhelpapp.utils.UIUtils;

public class SetNickNameActivity extends BaseActivity {
    private EditText editText;
    @Override
    protected int getLayoutId() {
        return R.layout.activity_set_nick_name;
    }

    @Override
    protected void initView() {
        showToolBar(true,getString(R.string.go_set_nickName));

        editText = findViewById(R.id.et_input);
        String currentNickName = SpUtils.getInstance().get(CoreConstant.SpConstant.KEY_NICK_NAME,"");
        if (!TextUtils.isEmpty(currentNickName)) {
            editText.setText(currentNickName);
        }
    }

    public void confirm(View view) {
        String nickName = editText.getText().toString().trim();
        if (TextUtils.isEmpty(nickName)) {
            UIUtils.showToast(R.string.hint_please_input_nickname);
            return;
        }
        SpUtils.getInstance().put(CoreConstant.SpConstant.KEY_NICK_NAME, nickName);
        UIUtils.showToast(R.string.save_success);
        finish();
    }
}
